home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / e / stringnd.lha / stringnode_examples / StringNode_Example5.e < prev   
Text File  |  1995-11-07  |  1KB  |  51 lines

  1. /*
  2. ** StringNode Example-5
  3. **
  4. ** add(), search(), clear() AND change() methods.
  5. **
  6. ** (C)Copyright 1995 Fabio Rotondo
  7. **
  8. ** e-mail: fosft@intercom.it
  9. */
  10.  
  11. MODULE 'fabio/StringNode_oo'   -> Our MAGIC MODULE
  12.  
  13. PROC main()
  14.   DEF n:PTR TO stringnode      -> This is our OBJECT instance
  15.  
  16.   NEW n.stringnode()           -> OBJECT initialization
  17.  
  18.   n.add('Zorro')              -> Here we add some items...
  19.   n.add('Batman')
  20.   n.add('Superman')
  21.   n.add('Gold Drake')
  22.   n.add('Mandrake')
  23.   n.add('MOMMY')
  24.  
  25.   shwall(n)                   -> Here we see them
  26.  
  27.   n.search('momm')             -> The search is CASE insensitive AND match the first one ;)
  28.   WriteF('Current:\s\n', n.name()) -> Here we are!
  29.  
  30.   n.change('My Mommy')       -> Wow! Now MOMMY is My Mommy!!!
  31.   shwall(n)
  32.  
  33.   n.clear()                  -> Empty StringNode!
  34.   shwall(n)
  35.  
  36.   END n                       -> Remember ALWAYS TO end an OBJECT
  37. ENDPROC
  38.  
  39. PROC shwall(n:PTR TO stringnode)
  40.   WriteF('------- \d ----------\n', n.numitems())
  41.  
  42.   IF n.first()                      -> Here we go TO the first node item
  43.     REPEAT
  44.       WriteF('Node:\s\n', n.name()) -> Node STRING...
  45.     UNTIL n.succ() = FALSE          -> LOOP UNTIL the end
  46.   ELSE
  47.     WriteF('No Nodes in LIST...\n')
  48.   ENDIF
  49. ENDPROC
  50.  
  51.